package com.foreveredu.propms.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.transaction.annotation.Transactional;
import com.foreveredu.propms.domain.PageModel;
import com.foreveredu.propms.domain.District;
import com.foreveredu.propms.domain.SubDistrict;
import com.foreveredu.propms.persist.IDistrictDao;
import com.foreveredu.propms.persist.IOwnerDao;
import com.foreveredu.propms.persist.ISubDistrictDao;
import com.foreveredu.propms.service.IPropQueryService;

@Transactional
public class PropQueryService implements IPropQueryService {

	private ISubDistrictDao subDistrictDao = null;
	private IDistrictDao districtDao = null;
	private IOwnerDao ownerDao = null;
	   
	@Override
	public Map<String, Object> querySubPaidRate(SubDistrict sub, int year, int month) {
		Map<String, Object> queryMap = subDistrictDao.querySubPaidRate(sub,year,month);
		queryMap.put("sub", sub);
		return queryMap;
	}

	public void setSubDistrictDao(ISubDistrictDao subDistrictDao) {
		this.subDistrictDao = subDistrictDao;
	}

	public ISubDistrictDao getSubDistrictDao() {
		return subDistrictDao;
	}

	public void setDistrictDao(IDistrictDao districtDao) {
		this.districtDao = districtDao;
	}

	public IDistrictDao getDistrictDao() {
		return districtDao;
	}

	public IOwnerDao getOwnerDao() {
		return ownerDao;
	}

	public void setOwnerDao(IOwnerDao ownerDao) {
		this.ownerDao = ownerDao;
	}

	@Override
	public Map<String, Object> querySubMonthlyCharge(SubDistrict sub, int year, int month) {
		Map<String, Object> queryMap = subDistrictDao.querySubMonthlyCharge(sub,year,month);
		queryMap.put("sub", sub);
		queryMap.put("subName", sub.getName());
		return queryMap;
	}

	//根据小区查询所有的小区里面的户主缴费明细
	@Override
	public PageModel queryUserBySub(SubDistrict sub, int year, int month,int offset) {
		PageModel pageModel = 	subDistrictDao.queryUserBySub(sub,year,month, offset);
		return pageModel;
	}

	@Override
	public Map<String, Object> queryDistMonthlyCharge(District dist, int year,int month) {  
		Map<String , Object> queryMap = districtDao.queryDistMonthlyCharge(dist, year, month);
		queryMap.put("distName", dist.getName());
		return queryMap;
	}

	@Override
	public Map<String, Object> queryDistYearCharge(District dist, int year) {
		Map<String , Object> queryMap = districtDao.queryDistYearCharge(dist, year);
		queryMap.put("distName", dist.getName());
		return queryMap;
	}

	@Override
	public PageModel queryOweCollectCharge(int offset,SubDistrict sub, int year,
			int month) {
		return ownerDao.findOweCollectChargeBySub(offset,sub.getId(), year, month);
	}

	@Override
	public PageModel findAllOweCharge(int offset, int year,int month) {
		return ownerDao.findOweCollectChargeAll(offset, year, month);
	}

	@Override
	public PageModel findAllOwdCollectChargeList(int offset, int year, int month) {
		return ownerDao.findOweCollectChargeAllList(offset, year, month);
	}

	@Override
	public PageModel findOwdCollectChargeBySubList(int offset, SubDistrict sub,
			int year, int month) {
		return ownerDao.findOwdCollectChargeBySubList(offset, sub, year, month);
	}

	@Override
	public Map<String, Object> querySubMonthlyChargeYear(SubDistrict sub,
			int year) {
		Map<String, Object> queryMap = subDistrictDao.querySubMonthlyChargeYear(sub,year);
		queryMap.put("sub", sub);
		return queryMap;
	}

	@Override
	public PageModel queryIndividualCharge(SubDistrict sub, int year,
			int month, int offset, int chargeItemId) {
		PageModel pageModel = subDistrictDao.queryIndividualCharge(sub,year,month, offset,chargeItemId);
		return pageModel;
	}

	//把小区用户缴费导出数据到Excel
	@Override
	public List<Map<String, Object>> doQueryownerChargeToExcel(SubDistrict sub,
			int year, int month) {
		List<Map<String, Object>> queryList=subDistrictDao.doQueryownerChargeToExcel(sub, year, month);
		return queryList;
	}

	@Override
	public List<Map<String, Object>> queryIndividualChargeIntoExcel(
			SubDistrict sub, int year, int month, int chargeItemId) {
		List<Map<String, Object>> queryList = subDistrictDao.queryIndividualChargeIntoExcel(sub, year, month, chargeItemId);
		return queryList;
	}

	@Override
	public List<Map<String, Object>> findAllOwdCollectChargeList(int year,
			int month) {
		return ownerDao.findOweCollectChargeAllList( year, month);
	}

	@Override
	public List<Map<String, Object>> findAllOweCharge(int year, int month) {
		return ownerDao.findOweCollectChargeAll( year, month);
	}

	@Override
	public List<Map<String, Object>> findOwdCollectChargeBySubList(
			SubDistrict sub, int year, int month) {
		return ownerDao.findOwdCollectChargeBySubList( sub, year, month);
	}

	@Override
	public List<Map<String, Object>> queryOweCollectCharge(
			SubDistrict sub, int year, int month) {
		return ownerDao.findOweCollectChargeBySub(sub.getId(), year, month);
	}
}
